package com.lb.shopguide.adapter;

import android.graphics.Paint;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lb.shopguide.R;
import com.lb.shopguide.entity.ChooseMemberBean;
import com.lb.shopguide.util.pic.ImageLoaderUtils;
import com.yqritc.recyclerviewflexibledivider.FlexibleDividerDecoration;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.List;

/**
 * Created by kang on 2017/6/9.
 */

public class AdapterSelectMember extends BaseQuickAdapter<ChooseMemberBean, BaseViewHolder> implements HorizontalDividerItemDecoration.MarginProvider, FlexibleDividerDecoration.PaintProvider {
    public AdapterSelectMember(int layoutResId, List<ChooseMemberBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ChooseMemberBean item) {
        View view = helper.itemView;
        TextView tvMemberName = view.findViewById(R.id.tv_member_name);
        ImageView ivMember = view.findViewById(R.id.iv_member_logo);

        ImageLoaderUtils.displayCircle(mContext, ivMember, item.getHeadPicUrl());
        tvMemberName.setText(item.getTrueName() + "(" + item.getMobileNum() + ")");
    }

    @Override
    public int dividerLeftMargin(int position, RecyclerView parent) {
        return 190;
    }

    @Override
    public int dividerRightMargin(int position, RecyclerView parent) {
        return 0;
    }

    @Override
    public Paint dividerPaint(int position, RecyclerView parent) {
        Paint paint = new Paint();
        paint.setColor(mContext.getResources().getColor(R.color.sg_common_line_bg_dark));
        paint.setStrokeWidth(2);
        return paint;
    }
}
